# See LICENSE file for copyright and license details.

include config.mk

SRC = box.c crypt.c seal.c sign.c transfer_crypt.c
OBJ = $(SRC:.c=.o)

LIB = libmissive.a
INC = box.h  crypt.h  seal.h  sign.h transfer_crypt.h

PKG_STR = "\nIf this is a local install you may need to run:\n\t\
\"export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig\" \nto use this library.\n"

.PHONY: all install uninstall clean

all: $(LIB)

$(LIB): $(OBJ)
	@$(AR) -rcs $@ $(OBJ)

.c.o:
	@$(CC) $(CFLAGS) -c $<

install: $(LIB) $(INC) libmissive.pc
	@echo @ install missive to $(DESTDIR)$(PREFIX)
	@mkdir -p $(DESTDIR)$(PREFIX)/lib
	@cp $(LIB) $(DESTDIR)$(PREFIX)/lib/$(LIB)
	@mkdir -p $(DESTDIR)$(PREFIX)/include/missive
	@cp $(INC) $(DESTDIR)$(PREFIX)/include/missive/
	@echo @ install libmissive.pc to $(PREFIX)
	@printf $(PKG_STR)
	@mkdir -p $(PREFIX)/lib/pkgconfig
	@cp libmissive.pc $(PREFIX)/lib/pkgconfig/

uninstall:
	@echo @ uninstall missive from $(DESTDIR)$(PREFIX)
	@rm -f $(DESTDIR)$(PREFIX)/lib/$(LIB)
	@rm -rf $(DESTDIR)$(PREFIX)/include/missive/
	@rm -f $(PREFIX)/lib/pkgconfig/libmissive.pc

clean:
	rm -f $(LIB) $(OBJ)
